package talk

import org.springframework.aop.TrueClassFilter;

class TalkController {

	def scaffold = true;
	
	// Service pour avoir les services des talks
	def talkService
	
    def index() { }
	
	def newTalk()
	{
		// On cherche si on trouve un utilisateur pour ce couple [login, password]
		def user = User.findByPseudoAndPassword(flash['pseudo_connection'], flash['password_connection'])
		
		if(user != null)
		{
			params['pseudo_connection'] = flash['pseudo_connection']
			params['password_connection'] = flash['password_connection']
			flash.putAll(params)
			
			talkService.newTalk(user, params['newtalk'])
			redirect(controller: "user", action: "home")
		}
		else
		{
			redirect(controller: "user", action: 'login') // redirection sur la page de connexion
		}
	}
	

}
